package com.zzyl.serve.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.zzyl.common.core.domain.R;
import com.zzyl.serve.dto.NursingLevelDTO;
import com.zzyl.serve.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.serve.domain.NursingLevel;
import com.zzyl.serve.service.INursingLevelService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理等级Controller
 *
 * @author liyi
 * @date 2025-10-14
 */
@Api(tags = "护理等级相关接口")
@RestController
@RequestMapping("/serve/level")
public class NursingLevelController extends BaseController {
    @Autowired
    private INursingLevelService nursingLevelService;

    /**
     * 查询护理等级列表
     */
    @ApiOperation("查询护理等级列表")
    @PreAuthorize("@ss.hasPermi('serve:level:list')")
    @GetMapping("/list")
    public TableDataInfo list(
            @ApiParam(value = "护理等级查询条件", required = false) NursingLevel nursingLevel) {
        startPage();
        List<NursingLevelVo> list = nursingLevelService.selectNursingLevelList(nursingLevel);
        return getDataTable(list);
    }

//    /**
//     * 导出护理等级列表
//     */
//    @ApiOperation("导出护理等级列表" )
//    @PreAuthorize("@ss.hasPermi('serve:level:export')" )
//    @Log(title = "护理等级" , businessType = BusinessType.EXPORT)
//    @PostMapping("/export" )
//    public void export(
//            HttpServletResponse response,
//            @ApiParam(value = "护理等级导出条件" , required = false) NursingLevel nursingLevel) {
//        List<NursingLevelVo> listVo = nursingLevelService.selectNursingLevelList(nursingLevel);
//
//        ExcelUtil<NursingLevel> util = new ExcelUtil<NursingLevel>(NursingLevel. class);
//        util.exportExcel(response, list, "护理等级数据" );
//    }

    /**
     * 获取护理等级详细信息
     */
    @ApiOperation("获取护理等级详细信息")
    @PreAuthorize("@ss.hasPermi('serve:level:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(
            @ApiParam(value = "护理等级ID", required = true)
            @PathVariable("id") Integer id) {
        return success(nursingLevelService.selectNursingLevelById(id));
    }

    /**
     * 新增护理等级
     */
    @ApiOperation("新增护理等级")
    @PreAuthorize("@ss.hasPermi('serve:level:add')")
    @Log(title = "护理等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(
            @ApiParam(value = "护理等级信息", required = true)
            @RequestBody NursingLevelDTO nursingLevelDto) {
        return toAjax(nursingLevelService.insertNursingLevel(nursingLevelDto));
    }

    /**
     * 修改护理等级
     */
    @ApiOperation("修改护理等级")
    @PreAuthorize("@ss.hasPermi('serve:level:edit')")
    @Log(title = "护理等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(
            @ApiParam(value = "护理等级信息", required = true)
            @RequestBody NursingLevelDTO nursingLevelDTO) {
        return toAjax(nursingLevelService.updateNursingLevel(nursingLevelDTO));
    }

    /**
     * 删除护理等级
     */
    @ApiOperation("删除护理等级")
    @PreAuthorize("@ss.hasPermi('serve:level:remove')")
    @Log(title = "护理等级", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(
            @ApiParam(value = "护理等级ID数组", required = true, example = "1,2,3")
            @PathVariable Integer[] ids) {
        return toAjax(nursingLevelService.deleteNursingLevelByIds(ids));
    }

    /**
     * 查询护理等级
     */
    @ApiOperation("查询所有护理等级")
    @GetMapping("/all")
    public R<List<NursingLevel>> getLevel() {
        return R.ok(nursingLevelService.getLevel());
    }
}
